]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
windows: add .rc support to autotools builds
authorViktor Szakats <commit@vsz.me>
Sun, 18 Sep 2022 12:05:35 +0000 (12:05 +0000)
committerViktor Szakats <commit@vsz.me>
Sun, 18 Sep 2022 12:05:35 +0000 (12:05 +0000)
After this update autotools builds will compile and link `.rc` resources
to Windows executables. Bringing this feature on par with CMake and
Makefile.m32 builds. And also making it unnecessary to improvise these
steps manually, while monkey patching build files, e.g. [0].

You can customize the resource compiler via the `RC` envvar, and its
options via `RCFLAGS`.

This harmless warning may appear throughout the build, even though the
autotools manual documents [1] `RC` as a valid tag, and it fails when
omitting one:
`libtool:   error: ignoring unknown tag RC`

[0] https://github.com/curl/curl-for-win/blob/535f19060d4b708f72e75dd849409ce50baa1b84/curl-autotools.sh#L376-L382
[1] https://www.gnu.org/software/libtool/manual/html_node/Tags.html

Closes #9521

configure.ac
lib/Makefile.am
src/Makefile.am

index 25ff78cac851d8087c5cacb933eda7fabc525f0f..1f114002b15db30cbfd64e5a9a6d7e11d4e55a27 100644 (file)
@@ -55,6 +55,8 @@ CURL_CHECK_OPTION_ECH
 
 XC_CHECK_PATH_SEPARATOR
 
+LT_LANG([Windows Resource])
+
 #
 # save the configure arguments
 #
@@ -568,6 +570,7 @@ CURL_DARWIN_CFLAGS
 CURL_DARWIN_SYSTEMCONFIGURATION
 CURL_SUPPORTS_BUILTIN_AVAILABLE
 
+AM_CONDITIONAL([OS_WINDOWS], [test "$curl_cv_native_windows" = "yes"])
 
 dnl ************************************************************
 dnl switch off particular protocols
index 18ce47ea954adf66751bda72f45d4d2aa0427a4d..5d2df8bffb1761420e89e225366738197dd14155 100644 (file)
@@ -75,6 +75,12 @@ AM_CPPFLAGS += -DBUILDING_LIBCURL
 AM_LDFLAGS =
 AM_CFLAGS =
 
+# Makefile.inc provides the CSOURCES and HHEADERS defines
+include Makefile.inc
+
+libcurl_la_SOURCES = $(CSOURCES) $(HHEADERS)
+libcurlu_la_SOURCES = $(CSOURCES) $(HHEADERS)
+
 libcurl_la_CPPFLAGS_EXTRA =
 libcurl_la_LDFLAGS_EXTRA =
 libcurl_la_CFLAGS_EXTRA =
@@ -102,6 +108,11 @@ endif
 
 if USE_CPPFLAG_CURL_STATICLIB
 libcurl_la_CPPFLAGS_EXTRA += -DCURL_STATICLIB
+else
+if OS_WINDOWS
+libcurl_la_SOURCES += $(LIB_RCFILES)
+$(LIB_RCFILES): $(top_srcdir)/include/curl/curlver.h
+endif
 endif
 
 if DOING_CURL_SYMBOL_HIDING
@@ -117,12 +128,6 @@ libcurlu_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_STATICLIB -DUNITTESTS
 libcurlu_la_LDFLAGS = $(AM_LDFLAGS) -static $(LIBCURL_LIBS)
 libcurlu_la_CFLAGS = $(AM_CFLAGS)
 
-# Makefile.inc provides the CSOURCES and HHEADERS defines
-include Makefile.inc
-
-libcurl_la_SOURCES = $(CSOURCES) $(HHEADERS)
-libcurlu_la_SOURCES = $(CSOURCES) $(HHEADERS)
-
 CHECKSRC = $(CS_$(V))
 CS_0 = @echo "  RUN     " $@;
 CS_1 =
@@ -148,3 +153,9 @@ tidy:
 
 optiontable:
        perl optiontable.pl < $(top_srcdir)/include/curl/curl.h > easyoptions.c
+
+if OS_WINDOWS
+# Warning is "normal": libtool:   error: ignoring unknown tag RC
+.rc.lo:
+       $(LIBTOOL) --tag=RC --mode=compile $(RC) -I$(top_srcdir)/include $(RCFLAGS) -i $< -o $@
+endif
index 5d093da20483841a4fe6b1fc0babd89145da80ca..d9180b0b148270289302e95bf1f07663858aa05d 100644 (file)
@@ -55,6 +55,10 @@ include Makefile.inc
 
 # CURL_FILES comes from Makefile.inc
 curl_SOURCES = $(CURL_FILES)
+if OS_WINDOWS
+curl_SOURCES += $(CURL_RCFILES)
+$(CURL_RCFILES): tool_version.h
+endif
 
 # This might hold -Werror
 CFLAGS += @CURL_CFLAG_EXTRAS@
@@ -75,7 +79,7 @@ libcurltool_la_CPPFLAGS = $(AM_CPPFLAGS) \
                           -DCURL_STATICLIB -DUNITTESTS
 libcurltool_la_CFLAGS =
 libcurltool_la_LDFLAGS = -static $(LINKFLAGS)
-libcurltool_la_SOURCES = $(curl_SOURCES)
+libcurltool_la_SOURCES = $(CURL_FILES)
 endif
 
 CLEANFILES = tool_hugehelp.c
@@ -151,3 +155,9 @@ tidy:
 
 listhelp:
        (cd $(top_srcdir)/docs/cmdline-opts && ./gen.pl listhelp *.d) > tool_listhelp.c
+
+if OS_WINDOWS
+# Warning is "normal": libtool:   error: ignoring unknown tag RC
+.rc.o:
+       $(LIBTOOL) --tag=RC --mode=compile $(RC) -I$(top_srcdir)/include -DCURL_EMBED_MANIFEST $(RCFLAGS) -i $< -o $@
+endif