aboutsummaryrefslogtreecommitdiff
path: root/makefile.after
blob: cef71b839c435107520f4c570daf3ff355c6671f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
OBJS+=$(CSRCS:%.c=$(OBJDIR)$/%$(OBJEXT))
OBJS:=$(OBJS:%.cc=$(OBJDIR)$/%$(OBJEXT))

RESOBJS:=$(RESOURCES:%.rc=$(OBJDIR)$/%.res)

ifdef SUBDIRS
load_makefile $(SUBDIRS:%=%\makefile MAKESERVER=$(MAKESERVER) DEBUG=$(DEBUG);)
all: $(SUBDIRS:%=%\all)
endif


### Static library stuff ###
ifdef LIBRARY
LIBRARY_DIR := $(LIBRARY:%=$(OBJDIR)\%.lib)
PDB := $(LIBRARY_DIR:%.lib=%.pdb)

all: $(LIBRARY_DIR)

$(LIBRARY_DIR) : $(OBJS)
	$(AR) /OUT:$(relpath $@) $(OBJS)

endif # End static library stuff

ifdef SHAREDLIB
DEFFILE ?= $(SHAREDLIB:%=%.def)
LIBRARYS := $(SHAREDLIB:%=$(OBJDIR)\%.dll) $(SHAREDLIB:%=$(OBJDIR)\%.lib)
PDB := $(SHAREDLIB:%=$(OBJDIR)\%.pdb)
LINKFLAGS += /DLL /DEF:$(DEFFILE)

all: $(LIBRARYS)

$(LIBRARYS) : $(OBJS) $(INCLUDELIBFILES) $(RESOBJS) $(DEFFILE)
	$(LINK) $(LINKFLAGS) /OUT:$(relpath $(basename $@)).dll $(INCLUDELIBFILES) $(SYSTEMLIBS) $(LINKLIBS) $(OBJS)

endif

### WINAPP/TTYAPP stuff ###
ifeq (1,$(call OR, $(call NE,$(WINAPP)_,_) $(call NE,$(TTYAPP)_,_)))

ifdef WINAPP

load_makefile $(MHMAKECONF)\libwinmain\makefile MAKESERVER=0 DEBUG=$(DEBUG)
EXTRALIB := $(MHMAKECONF)\libwinmain\$(NOSERVOBJDIR)\libwinmain.lib

EXE := $(WINAPP:%=$(OBJDIR)\%.exe)
LINKFLAGS += /SUBSYSTEM:WINDOWS
else
EXE := $(TTYAPP:%=$(OBJDIR)\%.exe)
LINKFLAGS += /SUBSYSTEM:CONSOLE
endif

PDB := $(EXE:%.exe=%.pdb)

ifdef VS2008

MANIFESTFILE:=$(OBJDIR)\runtime.manifest

$(MANIFESTFILE):
	$(MHMAKECONF)/tools/genruntimemanifest $@ $(DEBUG)

endif

all: $(EXE)

$(EXE) :  $(OBJS) $(INCLUDELIBFILES) $(INCLUDENOSERVLIBFILES) $(RESOBJS) $(MANIFESTFILE) $(EXTRALIB)
ifndef VS2008
	$(LINK) $(LINKFLAGS) /OUT:$(relpath $@) $(INCLUDELIBFILES) $(INCLUDENOSERVLIBFILES) $(SYSTEMLIBS) $(LINKLIBS) $(EXTRALIB) $(OBJS) $(RESOBJS)
else
	$(LINK) $(LINKFLAGS) /MANIFEST:NO /OUT:$(relpath $@) $(INCLUDELIBFILES) $(INCLUDENOSERVLIBFILES) $(SYSTEMLIBS) $(LINKLIBS) $(EXTRALIB) $(OBJS) $(RESOBJS)
	mt -nologo -manifest $(MANIFESTFILE) -outputresource:$(relpath $@);\#1
endif

endif  # End WINAPP or TTYAPP stuff

ifeq ($(DEBUG),1)
COMMONCFLAGS += $(DEFINES:%=-D%) $(INCLUDES:%=-I%) -Fo$(relpath $@) -Fd"$(PDB)" $<
else
COMMONCFLAGS += $(DEFINES:%=-D%) $(INCLUDES:%=-I%) -Fo$(relpath $@) -Fd"$(PDB)" $<
#PDB=   # There is no PDB file generated in a release build
endif

ifeq ($(OBJDIRPREFIX),)
ifeq ($(DEBUG),1)
CLEANRULEPOSTFIX=debug
else
CLEANRULEPOSTFIX=release
endif
else
CLEANRULEPOSTFIX=$(OBJDIRPREFIX)
endif

.PHONY: all cleanall clean clean$(CLEANRULEPOSTFIX)

### Implicit rules ###
CREATEDIR=mkdir $@

$(OBJDIR) :
	$(CREATEDIR)

clean: clean$(CLEANRULEPOSTFIX)

clean$(CLEANRULEPOSTFIX):
	del -e $(OBJDIR)

$(OBJDIR)\%$(OBJEXT) : %.c
	$(CC) $(CCFLAGS) $(COMMONCFLAGS)

$(OBJDIR)\%$(OBJEXT) : $(OBJDIR)\%.c
	$(CC) $(CCFLAGS) $(COMMONCFLAGS)

$(OBJDIR)\%$(OBJEXT) : %.cc
	$(CC) $(CCFLAGS) /EHsc $(COMMONCFLAGS)

$(OBJDIR)\%.res : %.rc
	$(RC) $(RCFLAGS) $(RCDEFINES:%=-d "%") $(RCINCLUDES:%=-i %) -Fo$(relpath $@) $<

ifdef INC_BDF_RULES
load_makefile $(MHMAKECONF)\bdftopcf\makefile MAKESERVER=0 DEBUG=$(DEBUG)
load_makefile $(MHMAKECONF)\mkfontscale\makefile MAKESERVER=0 DEBUG=$(DEBUG)

#bdftopcf is dependent on zlib1.dll, so we need to add the directory of the zlib dll to the path env variable
PATH:=$(relpath $(MHMAKECONF)\zlib\$(NOSERVOBJDIR))\;$(PATH)
export PATH

$(DESTDIR)\%.pcf.gz: %.bdf
	@del -e $@
	$(BDFTOPCF) -t $< | gzip > $@

$(DESTDIR)\%.enc.gz: %.enc
	gzip -c < $< > $@
endif

ifdef DESTDIR
$(DESTDIR):
	$(CREATEDIR)
endif