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

Option to create xsnap-worker.a statically linkable library #54

Open
wants to merge 1 commit into
base: Agoric
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion xsnap/makefiles/mac/xsnap-worker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
%.o : %.c

GOAL ?= debug
# Providing LIB=1 CC=clang generates a statically linkable library
# build/lib/mac/$(GOAL)/xsnap-worker.a
# that exports xnsapMain instead of main.
LIB ?=
NAME = xsnap-worker
ifneq ($(VERBOSE),1)
MAKEFLAGS += --silent
Expand All @@ -19,6 +23,7 @@ TLS_DIR = $(CURDIR)/../../sources
XS_DIR = $(MODDABLE)/xs

BIN_DIR = $(BUILD_DIR)/bin/mac/$(GOAL)
LIB_DIR = $(BUILD_DIR)/lib/mac/$(GOAL)
INC_DIR = $(XS_DIR)/includes
PLT_DIR = $(XS_DIR)/platforms
SRC_DIR = $(XS_DIR)/sources
Expand Down Expand Up @@ -64,6 +69,9 @@ endif
ifeq ($(XSNAP_RANDOM_INIT),1)
C_OPTIONS += -DmxSnapshotRandomInit
endif
ifneq ("x$(LIB)","x")
C_OPTIONS += -DexportXsnapMain
endif

LIBRARIES = -framework CoreServices

Expand Down Expand Up @@ -133,18 +141,33 @@ VPATH += $(MODDABLE)/modules/data/text/decoder
VPATH += $(MODDABLE)/modules/data/text/encoder
VPATH += $(MODDABLE)/modules/data/base64

build: $(TMP_DIR) $(BIN_DIR) $(BIN_DIR)/$(NAME)
ifneq ("x$(LIB)","x")
build: build-lib
else
build: build-bin
endif

build-bin: $(TMP_DIR) $(BIN_DIR) $(BIN_DIR)/$(NAME)

build-lib: $(TMP_DIR) $(LIB_DIR) $(LIB_DIR)/$(NAME).a

$(TMP_DIR):
mkdir -p $(TMP_DIR)

$(BIN_DIR):
mkdir -p $(BIN_DIR)

$(LIB_DIR):
mkdir -p $(LIB_DIR)

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

$(LIB_DIR)/$(NAME).a: $(OBJECTS)
@echo "#" $(NAME) $(GOAL) ": ar" $(@F)
$(AR) q $(LIB_DIR)/$(NAME).a $(OBJECTS)

$(OBJECTS): $(TLS_DIR)/xsnap.h
$(OBJECTS): $(TLS_DIR)/xsnapPlatform.h
$(OBJECTS): $(PLT_DIR)/xsPlatform.h
Expand All @@ -161,5 +184,7 @@ $(TMP_DIR)/%.o: %.c
clean:
rm -rf $(BUILD_DIR)/bin/mac/debug/$(NAME)
rm -rf $(BUILD_DIR)/bin/mac/release/$(NAME)
rm -rf $(BUILD_DIR)/lib/mac/debug/$(NAME)
rm -rf $(BUILD_DIR)/lib/mac/release/$(NAME)
rm -rf $(BUILD_DIR)/tmp/mac/debug/$(NAME)
rm -rf $(BUILD_DIR)/tmp/mac/release/$(NAME)
4 changes: 4 additions & 0 deletions xsnap/sources/xsnap-worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,11 @@ static void fxSigPipeHandler(int sigNum)
}
}

#ifdef exportXsnapMain
int xsnapMain(int argc, char* argv[])
#else
int main(int argc, char* argv[])
#endif
{
int argi;
int argr = 0;
Expand Down