may have fixed annoying make clean bugs
[feisty_meow.git] / scripts / clam / cpp / rules.def
index 9183ab87bc86f6e7d10de81ffcc51d0d1970b5a0..73efdfd463d00e330bbd11d40777e0797ff4bc1d 100644 (file)
@@ -92,6 +92,8 @@ ifeq "$(COMPILER)" "GNU_WINDOWS"
     LOAD_FLAG_PREFIX += $(shell wx-config --libs $(UNICODE_FLAG_ADD) )
   endif
 
+LOAD_FLAG_PREFIX += -lwsock32 -lmswsock -shared
+
   ifneq "$(USE_CURL)" ""
     COMPILER_FLAGS += `curl-config --cflags`
     LOAD_FLAG_SUFFIX += `curl-config --libs`
@@ -163,8 +165,8 @@ ifneq "$(OP_SYSTEM)" "WIN32"
 endif
 
 # win32 compiler additions.
-ifeq "$(OP_SYSTEM)" "WIN32"
-#ifeq "$(COMPILER)" "VISUAL_CPP"
+#ifeq "$(OP_SYSTEM)" "WIN32"
+ifeq "$(COMPILER)" "VISUAL_CPP"
   # processes the def file for linkage, if one has been specified.
   ifneq "$(DEF_FILE)" ""
     LOAD_FLAG_PREFIX += -def:$(DEF_FILE)
@@ -207,11 +209,12 @@ ifeq "$(OP_SYSTEM)" "WIN32"
   endif
 
   ifneq "$(USE_CURL)" ""
-    # curl wants this win32 flag?
-    DEFINITIONS += _WIN32
+#    # curl wants this win32 flag?
+    DEFINITIONS += WIN32
     LOCAL_HEADERS += $(THIRD_PARTY_DIR)/curl/include
     LIBRARY_SEARCH_PATH += $(THIRD_PARTY_DIR)/curl/lib
-    LIBS_USED += libcurl.dll.a
+#    LIBS_USED += libcurl.dll.a
+    LIBS_USED += libcurl.lib
   endif
 
   ifneq "$(VCPP_USE_GUI)" ""
@@ -242,13 +245,14 @@ ifeq "$(OP_SYSTEM)" "WIN32"
   ifneq "$(USE_SSL)" ""
     LOCAL_HEADERS += $(THIRD_PARTY_DIR)/openssl/include
     LIBRARY_SEARCH_PATH += $(THIRD_PARTY_DIR)/openssl/lib
-    LIBS_USED += libeay32.lib
+    LIBS_USED += libcrypto.lib libssl.lib
     $(shell cp $(THIRD_PARTY_DIR)/openssl/lib/*dll $(EXECUTABLE_DIR) )
   endif
   
 endif
 
-ifeq "$(OP_SYSTEM)" "WIN32"
+#ifeq "$(OP_SYSTEM)" "WIN32"
+ifeq "$(COMPILER)" "VISUAL_CPP"
   # prep the actual source variable so that certain file names are translated.
   ACTUAL_RESX = $(RESX:%.resx=$(OBJECT_DIR)/%.resources)
   ACTUAL_RESX_FLAGS = $(ACTUAL_RESX:%=-ASSEMBLYLINKRESOURCE:%) 
@@ -264,14 +268,18 @@ ACTUAL_LOCAL_LIBS = $(TEMP_LOC1)
 # Create the list of objects from the list of source files.
 TEMP_OBJ1 = $(SOURCE:%.cpp=%.obj)
 TEMP_OBJ2 = $(TEMP_OBJ1:%.c=%.obj)
-ifeq "$(OP_SYSTEM)" "WIN32"
+ifeq "$(COMPILER)" "VISUAL_CPP"
   ifneq "$(OMIT_VERSIONS)" ""
     # remove version rc files if we're not dealing with versions.
     TEMP_OBJ3a = $(TEMP_OBJ2:%_version.rc=)
   else
     TEMP_OBJ3a = $(TEMP_OBJ2)
   endif
-  TEMP_OBJ3 = $(TEMP_OBJ3a:%.rc=%.res)
+  ifeq "$(COMPILER)" "VISUAL_CPP"
+    TEMP_OBJ3 = $(TEMP_OBJ3a:%.rc=%.res)
+  else
+    TEMP_OBJ3 = $(TEMP_OBJ3a)
+  endif
 else
   # replace this when supporting resource files on unix.
   TEMP_OBJ3 = $(TEMP_OBJ2:%.rc=)
@@ -327,7 +335,8 @@ MULTI_BUILD_CMD = $(CC) $(COMPILER_FLAGS) -c `cat $(BUILD_LIST_FILE)` $(OBJECT_N
 # support for allocations; if regular new and DEBUG_NEW get mixed together,
 # crashes used to result.  supposedly these are gone now at least.
 ifneq "$(USE_MFC)" ""
-  ifeq "$(OP_SYSTEM)" "WIN32"
+#  ifeq "$(OP_SYSTEM)" "WIN32"
+  ifeq "$(COMPILER)" "VISUAL_CPP"
     # set the flag that says we are doing mfc extension dlls.
     DEFINITIONS += _AFXDLL
     DEPENDENCY_DEFINITIONS += _MT _DLL
@@ -341,14 +350,20 @@ ifeq "$(OMIT_VERSIONS)" ""
   endif
 endif
 
-ifneq "$(GENDEPS)" ""
-  EXTRA_FIRST_TARGETS += gendeps
-endif
+# if we are cleaning up, then do not generate dependency file.
+ifeq "$(CLEAN)" ""
+  ifneq "$(GENDEPS)" ""
+    EXTRA_FIRST_TARGETS += gendeps
+  endif
 
 # only do the deps generation for makefiles that are properly marked.
 ifneq "$(findstring __BUILD_STATIC_APPLICATION__, $(DEFINITIONS))" ""
   # generate static build dependencies for all targets in the makefile.
   GENERATED_DEPS_LIST = $(TARGETS:%.exe=%.gendeps)
+else
+  GENERATED_DEPS_LIST =
+endif
+
 endif
 
 # Make sure that the directory for objects exists.
@@ -411,10 +426,12 @@ endif
 #      $(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$(TEMP)/$@
 #endif
 
+ifeq "$(CLEAN)" ""
 # recreate dependencies for static applications.
 %.gendeps: %.cpp
        @echo "Generating Static Deps: $*.cpp"
        $(CATCHER)$(CLAM_DIR)/cpp/buildor_gen_deps.sh "$*.cpp"
+endif
 
 ############################################################################
 
@@ -425,7 +442,7 @@ endif
 $(OBJECT_DIR)/%.obj: $(CURRENT_DIR)/%.cpp
 ifeq "$(NO_COMPILE)" ""
   ifneq "$(COMPILER)" "VISUAL_CPP"
-       @echo Building [$(shell basename $@)]
+       @echo Compiling Object [$(notdir $@)]
        $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi'
        $(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$@
   else
@@ -442,7 +459,7 @@ endif
 $(OBJECT_DIR)/%.obj: $(CURRENT_DIR)/%.c
 ifeq "$(NO_COMPILE)" ""
   ifneq "$(COMPILER)" "VISUAL_CPP"
-       @echo Building [$@]
+       @echo Compiling Object [$(notdir $@)]
        $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi'
        $(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$@
   else
@@ -456,7 +473,7 @@ endif
 
 # resource compiler for win32.
 
-ifeq "$(OP_SYSTEM)" "WIN32"
+ifeq "$(COMPILER)" "VISUAL_CPP"
 $(OBJECT_DIR)/%.res: %.rc $(PARAMETER_FILE)
   ifeq "$(NO_COMPILE)" ""
        @echo Resource [$@]
@@ -470,7 +487,7 @@ $(OBJECT_DIR)/%.resources: %.resx $(PARAMETER_FILE)
        $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi'
        $(VCS_ROOT)/../SDK/v1.1/bin/resgen $< $@
   endif
-else #non-win32
+else #non-visual studio
   # this platform probably does not use rc files.
 $(OBJECT_DIR)/%.res: %.rc
   ifeq "$(NO_COMPILE)" ""
@@ -488,7 +505,7 @@ endif
 
 ifeq "$(NO_COMPILE)" ""
 $(STATIC_LIBRARY_DIR)/%.library: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
-       $(HIDER)echo Static [$@]
+       $(HIDER)echo Building Static Library [$(notdir $@)]
        @echo $@ >$(DIRTY_FILE)
   ifeq "$(COMPILER)" "VISUAL_CPP"
        $(HIDESH)-c 'if [ -f $(BUILD_LIST_FILE) ]; then $(SHELL) $(CLAM_DIR)/cpp/rebuild_oldies.sh $(MULTI_BUILD_CMD); fi'
@@ -521,7 +538,7 @@ ifeq "$(NO_COMPILE)" ""
 $(DYNAMIC_LIBRARY_DIR)/%.dll: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(ACTUAL_RESX) $(PARAMETER_FILE) 
 #hmmm: use the res objects variable to rebuild res files as needed.
 ###$(RES_OBJECTS) 
-       $(HIDER)echo Dynamic [$@]
+       $(HIDER)echo Building Dynamic Library [$(notdir $@)]
        @echo $@ >$(DIRTY_FILE)
   ifeq "$(COMPILER)" "VISUAL_CPP"
        $(HIDESH)-c 'if [ -f $(BUILD_LIST_FILE) ]; then $(SHELL) $(CLAM_DIR)/cpp/rebuild_oldies.sh $(MULTI_BUILD_CMD); fi'
@@ -567,7 +584,7 @@ $(EXECUTABLE_DIR)/%.exe:
 
   ifeq "$(NO_COMPILE)" ""
 $(EXECUTABLE_DIR)/%.exe: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(ACTUAL_RESX) $(PARAMETER_FILE)
-       $(HIDER)echo Application [$@]
+       $(HIDER)echo Building Application [$(notdir $@)]
        @echo $@ >$(DIRTY_FILE)
     ifeq "$(COMPILER)" "VISUAL_CPP"
        $(HIDESH)-c 'if [ -f $(BUILD_LIST_FILE) ]; then $(SHELL) $(CLAM_DIR)/cpp/rebuild_oldies.sh $(MULTI_BUILD_CMD); fi'
@@ -593,7 +610,7 @@ $(EXECUTABLE_DIR)/%:
 
   ifeq "$(NO_COMPILE)" ""
 $(EXECUTABLE_DIR)/%: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
-       $(HIDER)echo Application [$@]
+       $(HIDER)echo Building Application [$(notdir $@)]
        @echo $@ >$(DIRTY_FILE)
        $(CATCHER)$(LINK_TOOL) $(EXE_FLAGS) $(LOAD_FLAG_PREFIX) $< $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)%) $(LOAD_FLAG_SUFFIX) $(LINKER_OUTPUT_FLAG)$@
 #hmmm: experimental item below.
@@ -611,7 +628,7 @@ endif
 
 ifeq "$(NO_COMPILE)" ""
 $(EXECUTABLE_DIR)/%.elf: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
-       $(HIDER)echo Application [$@]
+       $(HIDER)echo Building Application [$(notdir $@)]
        @echo $@ >$(DIRTY_FILE)
        $(CATCHER)$(LINK_TOOL) $(MAP) $(LOAD_FLAG_PREFIX) $< $(LINKER_COMMAND_FILE) $(STARTUP_OBJECT_FILE) $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)%) $(LOAD_FLAG_SUFFIX) $(LINKER_OUTPUT_FLAG)$@
 #$(^:force_rebuild=) 
@@ -650,7 +667,7 @@ endif
 ifneq "$(CLEAN)" ""
   NO_DEPS = t
   # no dependencies get left when we are cleaning up.
-  $(shell rm -f $(DEPS_FILE))
+#  $(shell rm -f $(DEPS_FILE))
 endif
 ifneq "$(NO_COMPILE)" ""
   # non compiling projects do not need dependencies.
@@ -662,15 +679,10 @@ ifneq "$(REBUILD)" ""
   $(shell rm -f $(DEPS_FILE))
 endif
 
-# includes the auto-dependency information.  the dependency file is checked
-# for being up-to-date.  if not, it gets rebuilt and the make is restarted.
-ifeq "$(NO_DEPS)" ""
-  include $(DEPS_FILE)
-endif
-
 # preserves intermediate files from being deleted.
 ifeq "$(CLEAN)" ""
-.PRECIOUS: $(OBJECT_DIR)/%.obj $(OBJECT_DIR)/%.res $(OBJECT_DIR)/%.resources
+.PRECIOUS: $(OBJECT_DIR)/%.obj $(OBJECT_DIR)/%.res $(OBJECT_DIR)/%.resources $(OBJECT_DIR)/%.deps
+#hmmm: added above deps.  maybe not right.
 endif
 
 # zaps things when they could not be created correctly.
@@ -688,6 +700,7 @@ ifneq "$(NO_DEPS)" ""
     $(DEPS_FILE): $(PARAMETER_FILE)
 
 else
+  ifeq "$(CLEAN)" ""
   deps: $(DEPS_FILE)
 
   # this causes the dependency file to be regenerated if the sources or libs
@@ -711,7 +724,7 @@ else
         $(DEPS_FILE): $(VERSION_RC_ROOT)_version.rc
       endif
     endif
-       @echo Dependencies [$(shell basename $@)]
+       @echo Dependencies [$(notdir $@)]
        -$(HIDESH)$(CLAM_DIR)/cpp/preconditions.sh
        @touch $@
 #      @echo dep adds: $(DEPENDENCY_ADDITIONS)
@@ -719,6 +732,12 @@ else
 #      $(CATCHER)$(CLAM_BINARY_DIR)/makedep$(EXE_END) $(DEPENDENCY_DEFINITIONS:%=-D%) $(DEPENDENCY_ADDITIONS) -f$@ -o.obj -p$(OBJECT_DIR)/ -w 420 $(COMPILER_HEADER_DIR:%=-X%) $(THIRD_PARTY_DIR:%=-X%) -- $(COMPILER_FLAGS) $(SOURCE) $(EXE_CPPS)
        @echo $@ >$(SUBMAKE_FLAG)
   endif # non-compile.
+ else # cleaning.
+    # makes the dependencies a no-op for cleaning.
+    deps: $(PARAMETER_FILE)
+
+    $(DEPS_FILE): $(PARAMETER_FILE)
+ endif
 endif # no-deps.
 
 ############################################################################
@@ -730,6 +749,22 @@ check_requirements:
  
 ############################################################################
 
+# includes the auto-dependency information.  the dependency file is checked
+# for being up-to-date.  if not, it gets rebuilt and the make is restarted.
+ifeq "$(CLEAN)" ""
+  ifeq "$(NO_DEPS)" ""
+
+    # thank the buddha for this bit of code, or at least thank this page:
+    # http://stackoverflow.com/questions/5553352/how-do-i-check-if-file-exists-in-makefile
+    ifneq ("$(wildcard $(DEPS_FILE))","")
+      include $(DEPS_FILE)
+    endif
+
+  endif
+endif
+
+############################################################################
+
 # calls the script for preparing output directories and such.
 pre_compilation:
        $(HIDESH)$(CLAM_DIR)/cpp/preconditions.sh