| 1 | # $Id: pdwin32.wat.post,v 1.4 2000-10-03 05:39:51 bird Exp $
 | 
|---|
| 2 | #
 | 
|---|
| 3 | # Odin32 API
 | 
|---|
| 4 | #
 | 
|---|
| 5 | # Common dll makefile rules (must be included at the last line of the makefile)
 | 
|---|
| 6 | #
 | 
|---|
| 7 | # If ORGTARGET is defined it is used to generate the importlibrary.
 | 
|---|
| 8 | #
 | 
|---|
| 9 | # Define NOTEXPDEF to remove the $(TARGET).lib and $(TARGET)exp.def rules.
 | 
|---|
| 10 | # Define EXETARGET to make an executable. (This also applies to pdwin32.mk.)
 | 
|---|
| 11 | # Define LOCALCLEAN if only the local directory is to be clean.
 | 
|---|
| 12 | # Define CLEAN2 to invoke a second clean rule named 'clean2'.
 | 
|---|
| 13 | # Define NOCLEAN to exclude the clean rule. (Remember to make your own!)
 | 
|---|
| 14 | #
 | 
|---|
| 15 | # New style: (define NEW_STYLE)
 | 
|---|
| 16 | # Define NO_ALL_RULE to not make default all rule.
 | 
|---|
| 17 | # Define NO_LIB_RULE to not make default lib rule.
 | 
|---|
| 18 | # Define NO_DLL_RULE to not make default dll rule.
 | 
|---|
| 19 | # Define NO_EXE_RULE to not make default exe rule.
 | 
|---|
| 20 | # Define NO_LNKFILE_RULE to not make default link-file rule.
 | 
|---|
| 21 | # Define NO_DEP_RULE to not make dependencies rule.
 | 
|---|
| 22 | # Define NO_CLEAN_RULE to not make clean rule (same as NOCLEAN - use this!).
 | 
|---|
| 23 | #
 | 
|---|
| 24 | 
 | 
|---|
| 25 | 
 | 
|---|
| 26 | !ifdef NEW_STYLE
 | 
|---|
| 27 | !ifndef EXETARGET
 | 
|---|
| 28 | 
 | 
|---|
| 29 | 
 | 
|---|
| 30 | # All rule - build objs, target dll, copies target to bin and makes libs.
 | 
|---|
| 31 | !ifndef NO_ALL_RULE
 | 
|---|
| 32 | all:    $(OBJDIR) \
 | 
|---|
| 33 |         $(OBJDIR)\$(TARGET).dll \
 | 
|---|
| 34 |         $(PDWIN32_BIN)\$(TARGET).dll \
 | 
|---|
| 35 |         lib
 | 
|---|
| 36 | !endif
 | 
|---|
| 37 | 
 | 
|---|
| 38 | 
 | 
|---|
| 39 | # Lib rule - build importlibrary (and evt. other libs)
 | 
|---|
| 40 | !ifndef NO_LIB_RULE
 | 
|---|
| 41 | lib:    $(TARGET).lib $(PDWIN32_LIB)\$(TARGET).lib
 | 
|---|
| 42 | !endif
 | 
|---|
| 43 | 
 | 
|---|
| 44 | 
 | 
|---|
| 45 | # Dll rule - builds the target dll.
 | 
|---|
| 46 | !ifndef NO_DLL_RULE
 | 
|---|
| 47 | $(OBJDIR)\$(TARGET).dll: $(OBJS) $(OBJDIR)\$(TARGET).lnk
 | 
|---|
| 48 |     $(LD2) @$(OBJDIR)\$(TARGET).lnk
 | 
|---|
| 49 | !endif
 | 
|---|
| 50 | 
 | 
|---|
| 51 | 
 | 
|---|
| 52 | # Linker file - creates the parameter file passed on to the linker.
 | 
|---|
| 53 | !ifndef NO_LNKFILE_RULE
 | 
|---|
| 54 | $(OBJDIR)\$(TARGET).lnk: makefile $(TARGET).def $(PDWIN32_INCLUDE)\pdwin32.wat.post
 | 
|---|
| 55 |     $(RM) $(OBJDIR)\$(TARGET).lnk2 $@
 | 
|---|
| 56 |     $(KDEF2WAT) $(TARGET).def $@ <<$(OBJDIR)\$(TARGET).lnk2
 | 
|---|
| 57 | $(LD2FLAGS)
 | 
|---|
| 58 | name $(OBJDIR)\$(TARGET).dll
 | 
|---|
| 59 | option map=$(OBJDIR)\$(TARGET).map
 | 
|---|
| 60 | file    {$(OBJS)}
 | 
|---|
| 61 | library {$(LIBS)}
 | 
|---|
| 62 | <<
 | 
|---|
| 63 | !endif
 | 
|---|
| 64 | 
 | 
|---|
| 65 | 
 | 
|---|
| 66 | # Dep rule - makes depenencies for C, C++ and Asm files.
 | 
|---|
| 67 | !ifndef NO_DEP_RULE
 | 
|---|
| 68 | dep:
 | 
|---|
| 69 |     $(DEPEND) -I$(PDWIN32_INCLUDE);$(PDWIN32_INCLUDE)\win \
 | 
|---|
| 70 |         *.c *.cpp *.h *.asm *.inc $(PDWIN32_INCLUDE)\*.h
 | 
|---|
| 71 | !endif
 | 
|---|
| 72 | 
 | 
|---|
| 73 | !else # !ifndef EXETARGET
 | 
|---|
| 74 | 
 | 
|---|
| 75 | 
 | 
|---|
| 76 | # All rule - build objs, target exe, copies target to bin.
 | 
|---|
| 77 | !ifndef NO_ALL_RULE
 | 
|---|
| 78 | all:    $(OBJDIR) \
 | 
|---|
| 79 |         $(OBJDIR)\$(TARGET).exe \
 | 
|---|
| 80 |         $(PDWIN32_BIN)\$(TARGET).exe
 | 
|---|
| 81 | !endif
 | 
|---|
| 82 | 
 | 
|---|
| 83 | 
 | 
|---|
| 84 | # Lib rule - dummy rule
 | 
|---|
| 85 | !ifndef NO_LIB_RULE
 | 
|---|
| 86 | lib:
 | 
|---|
| 87 | !endif
 | 
|---|
| 88 | 
 | 
|---|
| 89 | 
 | 
|---|
| 90 | # Exe rule - builds the target exe.
 | 
|---|
| 91 | !ifndef NO_EXE_RULE
 | 
|---|
| 92 | $(OBJDIR)\$(TARGET).exe: $(OBJSNOOBJDIR) $(TARGET).def $(OBJDIR)\$(TARGET).lnk
 | 
|---|
| 93 |     $(LD2) $(LD2FLAGS) @$(OBJDIR)\$(TARGET).lnk
 | 
|---|
| 94 | !endif
 | 
|---|
| 95 | 
 | 
|---|
| 96 | 
 | 
|---|
| 97 | # Linker file - creates the parameter file passed on to the linker.
 | 
|---|
| 98 | !ifndef NO_LNKFILE_RULE
 | 
|---|
| 99 | $(OBJDIR)\$(TARGET).lnk: makefile  $(PDWIN32_INCLUDE)\pdwin32.wat.post
 | 
|---|
| 100 |     $(RM) $(OBJDIR)\$(TARGET).lnk2 $@
 | 
|---|
| 101 |     $(KDEF2WAT) $(TARGET).def $@ <<$(OBJDIR)\$(TARGET).lnk2
 | 
|---|
| 102 | $(LD2FLAGS)
 | 
|---|
| 103 | name $(OBJDIR)\$(TARGET).dll
 | 
|---|
| 104 | option map=$(OBJDIR)\$(TARGET).map
 | 
|---|
| 105 | file    {$(OBJS)}
 | 
|---|
| 106 | library {$(LIBS)}
 | 
|---|
| 107 | <<
 | 
|---|
| 108 | !endif
 | 
|---|
| 109 | 
 | 
|---|
| 110 | 
 | 
|---|
| 111 | # Dep rule - makes depenencies for C, C++ and Asm files.
 | 
|---|
| 112 | !ifndef NO_DE_PRULE
 | 
|---|
| 113 | dep:
 | 
|---|
| 114 |     $(DEPEND) -I$(PDWIN32_INCLUDE);$(PDWIN32_INCLUDE)\win \
 | 
|---|
| 115 |         *.c *.cpp *.h *.asm *.inc $(PDWIN32_INCLUDE)\*.h
 | 
|---|
| 116 | !endif
 | 
|---|
| 117 | 
 | 
|---|
| 118 | 
 | 
|---|
| 119 | !endif # EXETARGET
 | 
|---|
| 120 | !endif # NEW_STYLE
 | 
|---|
| 121 | 
 | 
|---|
| 122 | 
 | 
|---|
| 123 | 
 | 
|---|
| 124 | 
 | 
|---|
| 125 | # Copy library rule.
 | 
|---|
| 126 | !ifndef ORGTARGET
 | 
|---|
| 127 | $(PDWIN32_LIB)\$(TARGET).lib: $(TARGET).lib
 | 
|---|
| 128 | !else
 | 
|---|
| 129 | $(PDWIN32_LIB)\$(ORGTARGET).lib: $(ORGTARGET).lib
 | 
|---|
| 130 | !endif
 | 
|---|
| 131 |     $(CP) $** $@
 | 
|---|
| 132 | 
 | 
|---|
| 133 | 
 | 
|---|
| 134 | # Copy dll rule.
 | 
|---|
| 135 | !ifndef EXETARGET
 | 
|---|
| 136 | $(PDWIN32_BIN)\$(TARGET).dll: $(OBJDIR)\$(TARGET).dll
 | 
|---|
| 137 | !else
 | 
|---|
| 138 | $(PDWIN32_BIN)\$(TARGET).exe: $(OBJDIR)\$(TARGET).exe
 | 
|---|
| 139 | !endif
 | 
|---|
| 140 |     cd $(OBJDIR)
 | 
|---|
| 141 |     $(MAPSYM) $(TARGET).map
 | 
|---|
| 142 |     cd ..\..
 | 
|---|
| 143 |     $(CP) $(OBJDIR)\$(TARGET).sym $(PDWIN32_BIN)
 | 
|---|
| 144 |     $(CP) $** $@
 | 
|---|
| 145 |     -$(CP) $** $(@D)..\..\$(@F)
 | 
|---|
| 146 |     -$(CP) $(OBJDIR)\$(TARGET).sym $(@D)..\..
 | 
|---|
| 147 | 
 | 
|---|
| 148 | 
 | 
|---|
| 149 | !ifndef NOTEXPDEF
 | 
|---|
| 150 | # make library from the <>exp.def file.
 | 
|---|
| 151 | !ifndef ORGTARGET
 | 
|---|
| 152 | $(TARGET).LIB: $(TARGET)exp.def
 | 
|---|
| 153 | !else
 | 
|---|
| 154 | $(ORGTARGET).LIB: $(ORGTARGET)exp.def
 | 
|---|
| 155 | !endif
 | 
|---|
| 156 |     $(IMPLIB) $(IMPLIBFLAGS) $@ $**
 | 
|---|
| 157 |     $(CP) $@ $(PDWIN32_LIB)
 | 
|---|
| 158 | 
 | 
|---|
| 159 | 
 | 
|---|
| 160 | # make the <>exp.def file.
 | 
|---|
| 161 | !ifndef ORGTARGET
 | 
|---|
| 162 | $(TARGET)exp.def: $(TARGET).def
 | 
|---|
| 163 | !else
 | 
|---|
| 164 | $(ORGTARGET)exp.def: $(ORGTARGET).def
 | 
|---|
| 165 | !endif
 | 
|---|
| 166 |     $(IMPDEF) $** $@
 | 
|---|
| 167 | !endif
 | 
|---|
| 168 | 
 | 
|---|
| 169 | 
 | 
|---|
| 170 | # Create the object directory.
 | 
|---|
| 171 | $(OBJDIR): .SYMBOLIC
 | 
|---|
| 172 |     @if not exist bin $(MKDIR) bin
 | 
|---|
| 173 |     @if not exist $(OBJDIR) $(MKDIR) $(OBJDIR)
 | 
|---|
| 174 | 
 | 
|---|
| 175 | 
 | 
|---|
| 176 | #
 | 
|---|
| 177 | # General clean rule. To clean more add it to CLEANEXTRAS!
 | 
|---|
| 178 | #
 | 
|---|
| 179 | !ifndef NOCLEAN
 | 
|---|
| 180 | !ifndef NO_CLEAN_RULE
 | 
|---|
| 181 | !ifndef CLEAN2
 | 
|---|
| 182 | clean: .SYMBOLIC
 | 
|---|
| 183 | !else
 | 
|---|
| 184 | clean:  clean2
 | 
|---|
| 185 | !endif
 | 
|---|
| 186 |     $(RM) *.LIB *.res *.map *.pch *.orc_asm \
 | 
|---|
| 187 | !if "$(OBJDIR)" != ""
 | 
|---|
| 188 |      $(OBJDIR)\* \
 | 
|---|
| 189 | !endif
 | 
|---|
| 190 | !ifndef LOCALCLEAN
 | 
|---|
| 191 |         $(PDWIN32_LIB)\$(TARGET).LIB \
 | 
|---|
| 192 | !ifndef EXETARGET
 | 
|---|
| 193 |         $(PDWIN32_BIN)\$(TARGET).dll $(TARGET)exp.def *.dll \
 | 
|---|
| 194 | !else
 | 
|---|
| 195 |         $(PDWIN32_BIN)\$(TARGET).exe *.exe \
 | 
|---|
| 196 | !endif
 | 
|---|
| 197 |         $(CLEANEXTRAS)
 | 
|---|
| 198 | !else
 | 
|---|
| 199 |         $(CLEANEXTRAS)
 | 
|---|
| 200 | !endif
 | 
|---|
| 201 | !endif
 | 
|---|
| 202 | !endif
 | 
|---|
| 203 | 
 | 
|---|
| 204 | 
 | 
|---|