Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Improve and align Makefiles #50

Open
wants to merge 7 commits into
base: Agoric
Choose a base branch
from
42 changes: 25 additions & 17 deletions xsnap/makefiles/lin/xsnap-worker.mk
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
% : %.c
%.o : %.c

GOAL ?= debug
# CONSTANTS
NAME = xsnap-worker
PLATFORM = lin

# REQUIRED INPUTS
MODDABLE = # /path/to/moddable/repo
XSNAP_VERSION =

# OPTIONAL INPUTS
GOAL ?= debug
# GOAL ?= release
EXTRA_DEPS =
VERBOSE =

ifneq ($(VERBOSE),1)
MAKEFLAGS += --silent
endif

EXTRA_DEPS =

# MODDABLE = $(CURDIR)/../../moddable
BUILD_DIR = $(CURDIR)/../../build
TLS_DIR = $(CURDIR)/../../sources

# BUILD_DIR = $(MODDABLE)/build
# TLS_DIR = ../../sources

XS_DIR = $(MODDABLE)/xs

BIN_DIR = $(BUILD_DIR)/bin/lin/$(GOAL)
BIN_DIR = $(BUILD_DIR)/bin/$(PLATFORM)/$(GOAL)
INC_DIR = $(XS_DIR)/includes
PLT_DIR = $(XS_DIR)/platforms
SRC_DIR = $(XS_DIR)/sources
TMP_DIR = $(BUILD_DIR)/tmp/lin/$(GOAL)/$(NAME)
TMP_DIR = $(BUILD_DIR)/tmp/$(PLATFORM)/$(GOAL)/$(NAME)

LIBRARIES = -ldl -lm -lpthread

C_OPTIONS = \
-fno-common \
Expand Down Expand Up @@ -56,9 +64,6 @@ ifeq ($(GOAL),debug)
else
C_OPTIONS += -O3
endif

LIBRARIES = -ldl -lm -lpthread

ifeq ($(XSNAP_RANDOM_INIT),1)
LIBRARIES += -lbsd
C_OPTIONS += -DmxSnapshotRandomInit
Expand Down Expand Up @@ -117,7 +122,7 @@ OBJECTS = \
$(TMP_DIR)/textencoder.o \
$(TMP_DIR)/modBase64.o \
$(TMP_DIR)/xsnapPlatform.o \
$(TMP_DIR)/xsnap-worker.o
$(TMP_DIR)/$(NAME).o

VPATH += $(SRC_DIR) $(TLS_DIR)
VPATH += $(MODDABLE)/modules/data/text/decoder
Expand Down Expand Up @@ -147,10 +152,13 @@ $(OBJECTS): $(INC_DIR)/xs.h
$(OBJECTS): $(EXTRA_DEPS)
$(TMP_DIR)/%.o: %.c
@echo "#" $(NAME) $(GOAL) ": cc" $(<F)
@$(if $(MODDABLE),,$(error MODDABLE=/path/to/moddable/repo is required))
$(CC) $< $(C_OPTIONS) -c -o $@

%.h:
@$(if $(MODDABLE),,$(error MODDABLE=/path/to/moddable/repo is required))

clean:
rm -rf $(BUILD_DIR)/bin/lin/debug/$(NAME)
rm -rf $(BUILD_DIR)/bin/lin/release/$(NAME)
rm -rf $(BUILD_DIR)/tmp/lin/debug/$(NAME)
rm -rf $(BUILD_DIR)/tmp/lin/release/$(NAME)
# Remove files for all values of $(GOAL).
rm -rf $(BUILD_DIR)/bin/$(PLATFORM)/*/$(NAME)
rm -rf $(BUILD_DIR)/tmp/$(PLATFORM)/*/$(NAME)
40 changes: 27 additions & 13 deletions xsnap/makefiles/lin/xsnap.mk
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
% : %.c
%.o : %.c

GOAL ?= debug
# CONSTANTS
NAME = xsnap
PLATFORM = lin

# REQUIRED INPUTS
MODDABLE = # /path/to/moddable/repo

# OPTIONAL INPUTS
GOAL ?= debug
# GOAL ?= release
EXTRA_DEPS =
VERBOSE =

ifneq ($(VERBOSE),1)
MAKEFLAGS += --silent
endif

BUILD_DIR = $(MODDABLE)/build
TLS_DIR = ../../sources
BUILD_DIR = $(CURDIR)/../../build
TLS_DIR = $(CURDIR)/../../sources

XS_DIR = $(MODDABLE)/xs

BIN_DIR = $(BUILD_DIR)/bin/lin/$(GOAL)
BIN_DIR = $(BUILD_DIR)/bin/$(PLATFORM)/$(GOAL)
INC_DIR = $(XS_DIR)/includes
PLT_DIR = $(XS_DIR)/platforms
SRC_DIR = $(XS_DIR)/sources
TMP_DIR = $(BUILD_DIR)/tmp/lin/$(GOAL)/$(NAME)
TMP_DIR = $(BUILD_DIR)/tmp/$(PLATFORM)/$(GOAL)/$(NAME)

LIBRARIES = -ldl -lm -lpthread

C_OPTIONS = \
-fno-common \
Expand Down Expand Up @@ -45,9 +58,6 @@ ifeq ($(GOAL),debug)
else
C_OPTIONS += -DmxBoundsCheck=1 -O3
endif

LIBRARIES = -ldl -lm -lpthread

ifeq ($(XSNAP_RANDOM_INIT),1)
LIBRARIES += -lbsd
C_OPTIONS += -DmxSnapshotRandomInit
Expand Down Expand Up @@ -106,7 +116,7 @@ OBJECTS = \
$(TMP_DIR)/textencoder.o \
$(TMP_DIR)/modBase64.o \
$(TMP_DIR)/xsnapPlatform.o \
$(TMP_DIR)/xsnap.o
$(TMP_DIR)/$(NAME).o

VPATH += $(SRC_DIR) $(TLS_DIR)
VPATH += $(MODDABLE)/modules/data/text/decoder
Expand All @@ -133,12 +143,16 @@ $(OBJECTS): $(SRC_DIR)/xsAll.h
$(OBJECTS): $(SRC_DIR)/xsScript.h
$(OBJECTS): $(SRC_DIR)/xsSnapshot.h
$(OBJECTS): $(INC_DIR)/xs.h
$(OBJECTS): $(EXTRA_DEPS)
$(TMP_DIR)/%.o: %.c
@echo "#" $(NAME) $(GOAL) ": cc" $(<F)
@$(if $(MODDABLE),,$(error MODDABLE=/path/to/moddable/repo is required))
$(CC) $< $(C_OPTIONS) -c -o $@

%.h:
@$(if $(MODDABLE),,$(error MODDABLE=/path/to/moddable/repo is required))

clean:
rm -rf $(BUILD_DIR)/bin/lin/debug/$(NAME)
rm -rf $(BUILD_DIR)/bin/lin/release/$(NAME)
rm -rf $(BUILD_DIR)/tmp/lin/debug/$(NAME)
rm -rf $(BUILD_DIR)/tmp/lin/release/$(NAME)
# Remove files for all values of $(GOAL).
rm -rf $(BUILD_DIR)/bin/$(PLATFORM)/*/$(NAME)
rm -rf $(BUILD_DIR)/tmp/$(PLATFORM)/*/$(NAME)
44 changes: 26 additions & 18 deletions xsnap/makefiles/mac/xsnap-worker.mk
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
% : %.c
%.o : %.c

GOAL ?= debug
# CONSTANTS
NAME = xsnap-worker
PLATFORM = mac

# REQUIRED INPUTS
MODDABLE = # /path/to/moddable/repo
XSNAP_VERSION =

# OPTIONAL INPUTS
GOAL ?= debug
# GOAL ?= release
EXTRA_DEPS =
VERBOSE =
MACOS_ARCH ?=
MACOS_VERSION_MIN ?= -mmacosx-version-min=10.7

ifneq ($(VERBOSE),1)
MAKEFLAGS += --silent
endif

EXTRA_DEPS =

# MODDABLE = $(CURDIR)/../../moddable
BUILD_DIR = $(CURDIR)/../../build
TLS_DIR = $(CURDIR)/../../sources

# BUILD_DIR = $(MODDABLE)/build
# TLS_DIR = ../../sources

XS_DIR = $(MODDABLE)/xs

BIN_DIR = $(BUILD_DIR)/bin/mac/$(GOAL)
BIN_DIR = $(BUILD_DIR)/bin/$(PLATFORM)/$(GOAL)
INC_DIR = $(XS_DIR)/includes
PLT_DIR = $(XS_DIR)/platforms
SRC_DIR = $(XS_DIR)/sources
TMP_DIR = $(BUILD_DIR)/tmp/mac/$(GOAL)/$(NAME)
TMP_DIR = $(BUILD_DIR)/tmp/$(PLATFORM)/$(GOAL)/$(NAME)

MACOS_ARCH ?=
MACOS_VERSION_MIN ?= -mmacosx-version-min=10.7
LIBRARIES = -framework CoreServices

C_OPTIONS = \
-fno-common \
Expand Down Expand Up @@ -65,8 +72,6 @@ ifeq ($(XSNAP_RANDOM_INIT),1)
C_OPTIONS += -DmxSnapshotRandomInit
endif

LIBRARIES = -framework CoreServices

LINK_OPTIONS = $(MACOS_VERSION_MIN) $(MACOS_ARCH)
ifneq ("x$(SDKROOT)", "x")
LINK_OPTIONS += -isysroot $(SDKROOT)
Expand Down Expand Up @@ -126,7 +131,7 @@ OBJECTS = \
$(TMP_DIR)/textencoder.o \
$(TMP_DIR)/modBase64.o \
$(TMP_DIR)/xsnapPlatform.o \
$(TMP_DIR)/xsnap-worker.o
$(TMP_DIR)/$(NAME).o

VPATH += $(SRC_DIR) $(TLS_DIR)
VPATH += $(MODDABLE)/modules/data/text/decoder
Expand Down Expand Up @@ -156,10 +161,13 @@ $(OBJECTS): $(INC_DIR)/xs.h
$(OBJECTS): $(EXTRA_DEPS)
$(TMP_DIR)/%.o: %.c
@echo "#" $(NAME) $(GOAL) ": cc" $(<F)
@$(if $(MODDABLE),,$(error MODDABLE=/path/to/moddable/repo is required))
$(CC) $< $(C_OPTIONS) -c -o $@

%.h:
@$(if $(MODDABLE),,$(error MODDABLE=/path/to/moddable/repo is required))

clean:
rm -rf $(BUILD_DIR)/bin/mac/debug/$(NAME)
rm -rf $(BUILD_DIR)/bin/mac/release/$(NAME)
rm -rf $(BUILD_DIR)/tmp/mac/debug/$(NAME)
rm -rf $(BUILD_DIR)/tmp/mac/release/$(NAME)
# Remove files for all values of $(GOAL).
rm -rf $(BUILD_DIR)/bin/$(PLATFORM)/*/$(NAME)
rm -rf $(BUILD_DIR)/tmp/$(PLATFORM)/*/$(NAME)
60 changes: 37 additions & 23 deletions xsnap/makefiles/mac/xsnap.mk
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
% : %.c
%.o : %.c

GOAL ?= debug
# CONSTANTS
NAME = xsnap
PLATFORM = mac

# REQUIRED INPUTS
MODDABLE = # /path/to/moddable/repo

# OPTIONAL INPUTS
GOAL ?= debug
# GOAL ?= release
EXTRA_DEPS =
VERBOSE =
MACOS_ARCH ?=
MACOS_VERSION_MIN ?= -mmacosx-version-min=10.7

ifneq ($(VERBOSE),1)
MAKEFLAGS += --silent
endif

BUILD_DIR = $(MODDABLE)/build
TLS_DIR = ../../sources
BUILD_DIR = $(CURDIR)/../../build
TLS_DIR = $(CURDIR)/../../sources

XS_DIR = $(MODDABLE)/xs

BIN_DIR = $(BUILD_DIR)/bin/mac/$(GOAL)
BIN_DIR = $(BUILD_DIR)/bin/$(PLATFORM)/$(GOAL)
INC_DIR = $(XS_DIR)/includes
PLT_DIR = $(XS_DIR)/platforms
SRC_DIR = $(XS_DIR)/sources
TMP_DIR = $(BUILD_DIR)/tmp/mac/$(GOAL)/$(NAME)
TMP_DIR = $(BUILD_DIR)/tmp/$(PLATFORM)/$(GOAL)/$(NAME)

MACOS_ARCH ?=
MACOS_VERSION_MIN ?= -mmacosx-version-min=10.7
LIBRARIES = -framework CoreServices

SHARED_OPTIONS =
ifneq ("x$(SDKROOT)", "x")
SHARED_OPTIONS += -isysroot $(SDKROOT)
endif

C_OPTIONS = \
-fno-common \
Expand All @@ -41,10 +58,8 @@ C_OPTIONS = \
-I$(PLT_DIR) \
-I$(SRC_DIR) \
-I$(TLS_DIR) \
-I$(TMP_DIR)
ifneq ("x$(SDKROOT)", "x")
C_OPTIONS += -isysroot $(SDKROOT)
endif
-I$(TMP_DIR) \
$(SHARED_OPTIONS)
ifeq ($(GOAL),debug)
C_OPTIONS += -DmxDebug=1 -g -O0 -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter
else
Expand All @@ -54,12 +69,7 @@ ifeq ($(XSNAP_RANDOM_INIT),1)
C_OPTIONS += -DmxSnapshotRandomInit
endif

LIBRARIES = -framework CoreServices

LINK_OPTIONS = $(MACOS_VERSION_MIN) $(MACOS_ARCH)
ifneq ("x$(SDKROOT)", "x")
LINK_OPTIONS += -isysroot $(SDKROOT)
endif
LINK_OPTIONS = $(MACOS_VERSION_MIN) $(MACOS_ARCH) $(SHARED_OPTIONS)

# C_OPTIONS += -fsanitize=address -fno-omit-frame-pointer
# LINK_OPTIONS += -fsanitize=address -fno-omit-frame-pointer
Expand Down Expand Up @@ -115,7 +125,7 @@ OBJECTS = \
$(TMP_DIR)/textencoder.o \
$(TMP_DIR)/modBase64.o \
$(TMP_DIR)/xsnapPlatform.o \
$(TMP_DIR)/xsnap.o
$(TMP_DIR)/$(NAME).o

VPATH += $(SRC_DIR) $(TLS_DIR)
VPATH += $(MODDABLE)/modules/data/text/decoder
Expand All @@ -132,7 +142,7 @@ $(BIN_DIR):

$(BIN_DIR)/$(NAME): $(OBJECTS)
@echo "#" $(NAME) $(GOAL) ": cc" $(@F)
$(CC) $(LINK_OPTIONS) $(LIBRARIES) $(OBJECTS) -o $@
$(CC) $(LINK_OPTIONS) $(OBJECTS) $(LIBRARIES) -o $@

$(OBJECTS): $(TLS_DIR)/xsnap.h
$(OBJECTS): $(TLS_DIR)/xsnapPlatform.h
Expand All @@ -142,12 +152,16 @@ $(OBJECTS): $(SRC_DIR)/xsAll.h
$(OBJECTS): $(SRC_DIR)/xsScript.h
$(OBJECTS): $(SRC_DIR)/xsSnapshot.h
$(OBJECTS): $(INC_DIR)/xs.h
$(OBJECTS): $(EXTRA_DEPS)
$(TMP_DIR)/%.o: %.c
@echo "#" $(NAME) $(GOAL) ": cc" $(<F)
@$(if $(MODDABLE),,$(error MODDABLE=/path/to/moddable/repo is required))
$(CC) $< $(C_OPTIONS) -c -o $@

%.h:
@$(if $(MODDABLE),,$(error MODDABLE=/path/to/moddable/repo is required))

clean:
rm -rf $(BUILD_DIR)/bin/mac/debug/$(NAME)
rm -rf $(BUILD_DIR)/bin/mac/release/$(NAME)
rm -rf $(BUILD_DIR)/tmp/mac/debug/$(NAME)
rm -rf $(BUILD_DIR)/tmp/mac/release/$(NAME)
# Remove files for all values of $(GOAL).
rm -rf $(BUILD_DIR)/bin/$(PLATFORM)/*/$(NAME)
rm -rf $(BUILD_DIR)/tmp/$(PLATFORM)/*/$(NAME)