Skip to content

Commit

Permalink
Makefile: Compile zlib .c files with DMD via importC
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Dec 16, 2023
1 parent fa6dcb7 commit c36d113
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 433 deletions.
44 changes: 6 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,58 +101,27 @@ else
DRUNTIME = $(DRUNTIME_PATH)/../generated/$(OS)/$(BUILD)/$(MODEL)/druntime.lib
endif

# Set CC and DMD
# Set DMD
ifeq ($(OS),win32wine)
CC = wine dmc.exe
DMD = wine dmd.exe
RUN = wine
else
DMD = $(DMD_DIR)/generated/$(OS)/$(BUILD)/$(MODEL)/dmd$(DOTEXE)
ifeq ($(MODEL),32omf)
CC = dmc
else ifeq ($(OS),windows)
CC = cl.exe
else
CC = cc
endif
RUN =
endif

# Set CFLAGS
OUTFILEFLAG = -o
# Set extra CFLAGS (for DMD - the zlib .c files are compiled via importC)
NODEFAULTLIB=-defaultlib= -debuglib=
CFLAGS=-O -P=-Ietc/c/zlib
ifeq (,$(findstring win,$(OS)))
CFLAGS=$(MODEL_FLAG) -fPIC -std=c11 -DHAVE_UNISTD_H
CFLAGS += -P=-DHAVE_UNISTD_H -P=-DHAVE_STDARG_H
# Bundled with the system library on OSX, and doesn't work with >= MacOS 11
ifneq (osx,$(OS))
NODEFAULTLIB += -L-lpthread -L-lm
endif
ifeq ($(BUILD),debug)
CFLAGS += -g
else
CFLAGS += -O3
endif
else
ifeq ($(MODEL),32omf)
CFLAGS=-DNO_snprintf
ifeq ($(BUILD),debug)
CFLAGS += -g
else
CFLAGS += -O
endif
else # win64/win32coff
OUTFILEFLAG = /Fo
CFLAGS += /nologo /Zl /GS-
ifeq ($(BUILD),debug)
CFLAGS += /Z7
else
CFLAGS += /O2
endif
endif
endif
ifeq (osx,$(OS))
ifeq (64,$(MODEL))
CFLAGS+=--target=x86_64-darwin-apple # ARM cpu is not supported by dmd
CFLAGS += -P=-DNO_snprintf
endif
endif

Expand Down Expand Up @@ -351,8 +320,7 @@ lib: $(LIB)
dll: $(ROOT)/libphobos2.so

$(ROOT)/%$(DOTOBJ): %.c
@[ -d $(dir $@) ] || mkdir -p $(dir $@) || [ -d $(dir $@) ]
$(CC) -c $(CFLAGS) $< $(OUTFILEFLAG)$@
$(DMD) -c $(DFLAGS) $(CFLAGS) -of$@ $<

$(LIB): $(OBJS) $(ALL_D_FILES) $(DRUNTIME)
$(DMD) $(DFLAGS) -lib -of$@ $(DRUNTIME) $(D_FILES) $(OBJS)
Expand Down
95 changes: 0 additions & 95 deletions etc/c/zlib/linux.mak

This file was deleted.

99 changes: 0 additions & 99 deletions etc/c/zlib/osx.mak

This file was deleted.

97 changes: 0 additions & 97 deletions etc/c/zlib/win32.mak

This file was deleted.

Loading

0 comments on commit c36d113

Please sign in to comment.