Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #
  2. # BEGIN COPYRIGHT BLOCK
  3. # This Program is free software; you can redistribute it and/or modify it under
  4. # the terms of the GNU General Public License as published by the Free Software
  5. # Foundation; version 2 of the License.
  6. #
  7. # This Program is distributed in the hope that it will be useful, but WITHOUT
  8. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  10. #
  11. # You should have received a copy of the GNU General Public License along with
  12. # this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  13. # Place, Suite 330, Boston, MA 02111-1307 USA.
  14. #
  15. # In addition, as a special exception, Red Hat, Inc. gives You the additional
  16. # right to link the code of this Program with code not covered under the GNU
  17. # General Public License ("Non-GPL Code") and to distribute linked combinations
  18. # including the two, subject to the limitations in this paragraph. Non-GPL Code
  19. # permitted under this exception must only link to the code of this Program
  20. # through those well defined interfaces identified in the file named EXCEPTION
  21. # found in the source code files (the "Approved Interfaces"). The files of
  22. # Non-GPL Code may instantiate templates or use macros or inline functions from
  23. # the Approved Interfaces without causing the resulting work to be covered by
  24. # the GNU General Public License. Only Red Hat, Inc. may make changes or
  25. # additions to the list of Approved Interfaces. You must obey the GNU General
  26. # Public License in all respects for all of the Program code and other code used
  27. # in conjunction with the Program except the Non-GPL Code covered by this
  28. # exception. If you modify this file, you may extend this exception to your
  29. # version of the file, but you are not obligated to do so. If you do not wish to
  30. # provide this exception without modification, you must delete this exception
  31. # statement from your version and license this file solely under the GPL without
  32. # exception.
  33. #
  34. #
  35. # Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  36. # Copyright (C) 2005 Red Hat, Inc.
  37. # All rights reserved.
  38. # END COPYRIGHT BLOCK
  39. #
  40. #
  41. # Makefile for ldaputil unit test.
  42. #
  43. BUILD_ROOT=../../..
  44. MODULE=LibLdapUtil
  45. OBJDEST=.
  46. UTESTDEST=utest
  47. include $(BUILD_ROOT)/nsconfig.mk
  48. MODULE_CFLAGS=-I$(NSROOT)/include
  49. include $(INCLUDE_DEPENDS)
  50. TESTFLAGS = -DUTEST -DDBG_PRINT -DDONT_USE_LDAP_SSL
  51. CC=CC
  52. PURIFY=
  53. CSRC = stubs.c
  54. CPPSRC = auth.cpp
  55. TSRC = authtest
  56. SRC = $(CSRC) $(CPPSRC) $(TSRC)
  57. XSRC = ../ldapauth.c ../ldapdb.c ../errors.c ../dbconf.c ../certmap.c ../ldapauth.c ../init.c ../encode.c
  58. COBJ = $(CPPSRC:%.cpp=%.o) $(CSRC:%.c=%.o)
  59. XOBJ = $(XSRC:../%.c=../utest/%.o)
  60. ifeq ($(ARCH), WINNT)
  61. BINS=./auth.exe
  62. LDAP_LIBLINK = $(addprefix $(LDAP_LIBPATH)/, $(addsuffix .lib, $(LDAP_LIBNAMES)))
  63. XLIBS = ${LDAP_LIBLINK}
  64. LOCAL_LINK_EXE = link -OUT:"$@" /MAP $(ARCH_LINK_DEBUG) $(LCFLAGS) /NOLOGO \
  65. /PDB:NONE /INCREMENTAL:NO /SUBSYSTEM:windows $(XLIBS)
  66. else
  67. BINS = auth
  68. LDAP_LIBLINK = -L$(LDAP_LIBPATH) $(addprefix -l, ${LDAP_SOLIB_NAMES})
  69. endif
  70. ifeq ($(ARCH), SOLARIS)
  71. XLIBS = -R$(LDAP_LIBPATH) ${LDAP_LIBLINK} $(LIBNSPR) $(LIBSEC) -lthread -lposix4 -lsocket -lnsl -ldl
  72. else
  73. ifeq ($(ARCH), IRIX)
  74. XLIBS = ${LDAP_LIBLINK} $(LIBNSPR) $(LIBSEC)
  75. else
  76. ifeq ($(ARCH), WINNT)
  77. echo "XLIBS = ${XLIBS}"
  78. else
  79. #Other UNIX platforms
  80. XLIBS = -R$(LDAP_LIBPATH) ${LDAP_LIBLINK} $(LIBNSPR) $(LIBSEC) -lthread -lposix4 -lsocket -lnsl -ldl
  81. endif
  82. endif
  83. endif
  84. PLUGIN = plugin.so
  85. all: $(LIBLDAP) $(COBJ) $(TSRC) ${BINS} $(PLUGIN)
  86. ./authtest 2> test.out
  87. diff test.out test.ref
  88. @echo
  89. @echo "The unit test is passed if there is no diff output, and the"
  90. @echo "Purify window shows no errors and 0 bytes leaked."
  91. @echo
  92. @echo "Run - gmake coverage - manually to get code coverage analysis."
  93. @echo
  94. auth: $(XOBJ) $(COBJ)
  95. $(PURIFY) $(CC) $(XLIBS) $^ -o $@
  96. auth.exe: $(XOBJ) $(COBJ)
  97. $(PURIFY) $(LOCAL_LINK_EXE) $(XOBJ) $(COBJ) ${XLIBS}
  98. testcert: testcert.o $(XOBJ) ../utest/cert.o
  99. $(PURIFY) $(CC) $(XLIBS) $^ -o $@
  100. %.o:%.c
  101. $(PURIFY) $(CC) -c $(CFLAGS) $(TESTFLAGS) $(MCC_INCLUDE) $< -o $@
  102. ../utest/%.o:../%.c
  103. $(PURIFY) $(CC) -c $(CFLAGS) $(TESTFLAGS) $(MCC_INCLUDE) -I.. $< -o $(OBJDEST)/$*.o
  104. ../utest/%.o:../%.cpp
  105. $(PURIFY) $(CC) -c $(CFLAGS) $(TESTFLAGS) $(MCC_INCLUDE) -I.. $< -o $(OBJDEST)/$*.o
  106. PLUGIN_INC = ./include
  107. $(PLUGIN_INC):
  108. mkdir -p include
  109. certmap.h: $(BUILD_ROOT)/include/ldaputil/extcmap.h
  110. \rm -rf $(PLUGIN_INC)/$@
  111. cp $^ $(PLUGIN_INC)/$@
  112. ldap.h: $(LDAP_INCLUDE)/ldap.h
  113. \rm -rf $(PLUGIN_INC)/$@
  114. cp $^ $(PLUGIN_INC)/$@
  115. lber.h: $(LDAP_INCLUDE)/lber.h
  116. \rm -rf $(PLUGIN_INC)/$@
  117. cp $^ $(PLUGIN_INC)/$@
  118. example.o: example.c $(PLUGIN_INC) certmap.h ldap.h lber.h
  119. $(CC) -c -I$(PLUGIN_INC) $*.c -o $(OBJDEST)/$*.o
  120. plugin.o: plugin.c $(PLUGIN_INC) certmap.h ldap.h lber.h
  121. $(PURIFY) $(CC) -c -I. -I$(PLUGIN_INC) $*.c -o $(OBJDEST)/$*.o
  122. $(PLUGIN): plugin.o
  123. $(LINK_DLL) $^