Having trouble using AC_CHECK_LIB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm trying to replace the hand-made Makefile of Project: Starfighter
with Autoconf and Automake files. This is my first time using Autoconf
and Automake, so I'm kind of learning as I go along.

I'm stuck at one part. Project: Starfighter requires SDL_Image and
SDL_Mixer from SDL2 in order to build, so I'm trying to check for them
by using AC_CHECK_LIB with functions defined by SDL_Image and
SDL_Mixer. These are my checks (you can see the attached file for the
full configure.ac):

    AC_CHECK_LIB([SDL2], [SDL_Init], [], [echo "Error: SDL2 not
found." ; exit 1])
    AC_CHECK_LIB([SDL2], [IMG_Load], [], [echo "Error: SDL_Image not
found." ; exit 1])
    AC_CHECK_LIB([SDL2], [Mix_LoadWAV], [], [echo "Error: SDL_Mixer
not found." ; exit 1])

When I generate and run a configure script, the first check always
passes, but the second and third always fail (I checked the third by
removing the exit call from the second one). But I know I have
SDL_Image and SDL_Mixer for SDL2, because I can compile Project:
Starfighter with the hand-made Makefile (attached) just fine.

So, I suppose I have two questions:

1. Am I doing something I shouldn't be doing? (e.g. is it bad to check
a library more than once?)

2a. If so, what am I supposed to do to check for something like
SDL_Image and SDL_Mixer (where it's in the same library, but
separately packaged)?

2b. If not, how can I figure out what's wrong?

- -- 
Julian Marchant
https://onpon4.github.io

Protect your privacy with GnuPG:
https://emailselfdefense.fsf.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQEcBAEBAgAGBQJU878NAAoJELP1a+89AVMCXrIH/Am5k2iyuvedRsknWfqSNzqD
it7cfDRXlaKb9Akbla1CWu98/IuueT8JTLxrsRyMMiRDSO9owD97vCfvvsye9o3+
RflG6vn62Ex76wg0voxIM5oKrpe7jut9RzHXTA+Won5CNohQ7kiF3e341PrYAZcq
GT4OxwRmabhOssyxtJfZroRVrttZmhBaUDJNO0XKMR9hk8cX+YdOscbqO9gOw4Wo
40eRtz/DjIDGpQWmormcY/huH3iNlpLwPlQXiP7vF7VNE3RX3rS4ZiKMFpCuZN2Z
nIqjAu7uMTzCYtLKJZlDllASP34KYK37mBd33Eapofn3cHY9TOn9pVeB/vaN+as=
=4GIi
-----END PGP SIGNATURE-----
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
# Copyright (c) 2015 Julian Marchant <onpon4@xxxxxxxxxx>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

AC_PREREQ([2.69])
AC_INIT([Project: Starfighter], [1.3], [onpon4@xxxxxxxxxx])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
AC_CONFIG_SRCDIR([src/Starfighter.cpp])
AC_CONFIG_HEADERS([config.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_INSTALL

# Checks for libraries.
AC_CHECK_LIB([SDL2], [SDL_Init], [], [echo "Error: SDL2 not found." ; exit 1])
AC_CHECK_LIB([SDL2], [IMG_Load], [], [echo "Error: SDL_Image not found." ; exit 1])
AC_CHECK_LIB([SDL2], [Mix_LoadWAV], [], [echo "Error: SDL_Mixer not found." ; exit 1])

# Checks for header files.
AC_CHECK_HEADERS([stdlib.h string.h time.h math.h sys/types/h sys/stat.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_INT16_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T

# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([atexit mkdir])

AC_CONFIG_FILES([
	Makefile
	src/Makefile
])
AC_OUTPUT
CXXFLAGS ?= -O2 -Wall -g
CXXFLAGS += `pkg-config --cflags sdl2 SDL2_image SDL2_mixer` -DLINUX -lSDL2
LIBS = `pkg-config --libs sdl2 SDL2_image SDL2_mixer`
OBJS = ai.o aliens.o audio.o bullets.o cargo.o collectable.o comms.o debris.o events.o explosions.o game.o globals.o graphics.o init.o intermission.o loadSave.o messages.o misc.o missions.o player.o resources.o script.o shop.o Starfighter.o title.o weapons.o

VERSION = 1.3-dev
PROG = starfighter
DOCS = docs/*
DATA = data gfx sound
DATAFILES = data/* gfx/* sound/*

PREFIX ?= /usr
BINDIR ?= $(PREFIX)/games/
DATADIR ?= $(PREFIX)/share/games/parallelrealities/
DOCDIR ?= $(PREFIX)/share/doc/$(PROG)/

# top-level rule to create the program.
ALL = $(PROG)

all: $(ALL)

# compiling other source files.
%.o: src/%.cpp src/*.h
	$(CXX) $(CXXFLAGS) -c -DVERSION=\"$(VERSION)\" -DDATADIR=\"$(DATADIR)\" $<

# linking the program.
$(PROG): $(OBJS)
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJS) -o $(PROG) $(LIBS)

# cleaning everything that can be automatically recreated with "make".
clean:
	$(RM) $(OBJS) $(ALL)

# install
install: $(ALL)
	mkdir -p $(DESTDIR)$(BINDIR)
	mkdir -p $(DESTDIR)$(DATADIR)
	mkdir -p $(DESTDIR)$(DOCDIR)

	install -m 755 $(PROG) $(DESTDIR)$(BINDIR)$(PROG)
	cp -pr $(DATA) $(DESTDIR)$(DATADIR)
	cp -p $(DOCS) $(DESTDIR)$(DOCDIR)

optimise:
	advpng -z gfx/*.png
	jpegoptim --strip-all gfx/*.jpg

dist:
	rm -rf starfighter-$(VERSION)
	mkdir starfighter-$(VERSION)
	cp --parents -lt starfighter-$(VERSION) `git ls-files`
	git log >starfighter-$(VERSION)/ChangeLog
	tar czf starfighter-$(VERSION).tar.gz starfighter-$(VERSION)
	rm -rf starfighter-$(VERSION)

.PHONY: all clean install optimise dist

Attachment: configure.ac.sig
Description: PGP signature

Attachment: Makefile-old.sig
Description: PGP signature

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux