diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,175 +3,187 @@
 `arch-hs` uses [PVP Versioning][1].
 The changelog is available [on GitHub][2].
 
+## 0.10.1.0
+
+- Always generate `-f` or `-f-` for each flag in PKGBUILD
+
+- Better prompt for missing packages
+
+- Fix the bug that resolved targets were not filtered out correctly when processing sub-libraries
+
+- Update name preset
+
 ## 0.10.0.0
 
-* Add `arch-hs-sync list` to list Haskell packages in [community]
+- Add `arch-hs-sync list` to list Haskell packages in [community]
 
-* Remove generating meta package
+- Remove generating meta package
 
-* Add `--install-deps` to call pacman to install all dependencies of a target
+- Add `--install-deps` to call pacman to install all dependencies of a target
 
-* Fix the list of packages to be packed is not consistent
+- Fix the list of packages to be packed is not consistent
 
-* Add `--no-skip-missing` to consider abnormal dependencies in packaging
+- Add `--no-skip-missing` to consider abnormal dependencies in packaging
 
-* Update dependency versions
+- Update dependency versions
 
-* Update name preset
+- Update name preset
 
 ## 0.9.1.0
 
-* Support Cabal 3.4
+- Support Cabal 3.4
 
-* Use the version of [`haskell-ghc`](https://archlinux.org/packages/community/x86_64/ghc/) to evaluate condition trees
+- Use the version of [`haskell-ghc`](https://archlinux.org/packages/community/x86_64/ghc/) to evaluate condition trees
 
-* Fix the bug that sub-lib components appear wrongly in results
+- Fix the bug that sub-lib components appear wrongly in results
 
 ## 0.9.0.0
 
-* Remove `arch-hs-submit` executable
+- Remove `arch-hs-submit` executable
 
-* Add `arch-hs-sync` executable, which has two commands:
-  * `arch-hs-sync submit` - the same as `arch-hs-submit` previously
-  * `arch-hs-sync check` - check version inconsistencies between [community] and Hackage
+- Add `arch-hs-sync` executable, which has two commands:
 
-* Improve CLI options: 
-  * values of `--skip` and `--flag` are no longer separated by comma
-  * the options can be set many times, for example: `arch-hs -f packageA:flagA:true -f packageB:flagB:false`
+  - `arch-hs-sync submit` - the same as `arch-hs-submit` previously
+  - `arch-hs-sync check` - check version inconsistencies between [community] and Hackage
 
-* Update name preset
+- Improve CLI options:
 
+  - values of `--skip` and `--flag` are no longer separated by comma
+  - the options can be set many times, for example: `arch-hs -f packageA:flagA:true -f packageB:flagB:false`
+
+- Update name preset
+
 ## 0.8.0.0
 
-* Fix the bug that unable to run with dependency-free packages
+- Fix the bug that unable to run with dependency-free packages
 
-* Do not generate PKGBUILDs for missing dependencies of the target
+- Do not generate PKGBUILDs for missing dependencies of the target
 
-* Support resolving sub-libraries in `arch-hs-diff`
+- Support resolving sub-libraries in `arch-hs-diff`
 
-* Remove `falseList`, which `arch-hs-submit` no longer uses
+- Remove `falseList`, which `arch-hs-submit` no longer uses
 
 ## 0.7.1.0
 
-* Bump ghc version to 8.10.4
+- Bump ghc version to 8.10.4
 
-* Fix some output formats
+- Fix some output formats
 
 ## 0.7.0.0
 
-* Support dumping output of `arch-hs` to JSON
+- Support dumping output of `arch-hs` to JSON
 
-* Support resolving setup dependencies in `arch-hs-diff`
+- Support resolving setup dependencies in `arch-hs-diff`
 
-* Fix wrong concatenation direction of differentiating dependencies in `arch-hs-diff`
+- Fix wrong concatenation direction of differentiating dependencies in `arch-hs-diff`
 
-* Replace `req` with [`arch-web`](https://github.com/berberman/arch-web) and `http-client`
+- Replace `req` with [`arch-web`](https://github.com/berberman/arch-web) and `http-client`
 
-* Make `getLatestSHA256` become total function
+- Make `getLatestSHA256` become total function
 
 ## 0.6.2.0
 
-* Use `Doc` to print prompt messages
+- Use `Doc` to print prompt messages
 
-* Fix wrong line feeds in `arch-hs-diff`
+- Fix wrong line feeds in `arch-hs-diff`
 
 ## 0.6.1.0
 
-* Show dependens and makedepends in `arch-hs-diff` even if there is no difference between two target versions
+- Show dependens and makedepends in `arch-hs-diff` even if there is no difference between two target versions
 
-* Bump ghc version to 8.10.3
+- Bump ghc version to 8.10.3
 
-* Fix an alignment error in `arch-hs-submit`
+- Fix an alignment error in `arch-hs-submit`
 
 ## 0.6.0.0
 
-* Adopt [prettyprinter](https://hackage.haskell.org/package/prettyprinter)
+- Adopt [prettyprinter](https://hackage.haskell.org/package/prettyprinter)
 
-* Support resolving `pkgconfigDepends` and `extraLibs` using pacman files db
+- Support resolving `pkgconfigDepends` and `extraLibs` using pacman files db
 
-* Support resolving custom-setup dependencies
+- Support resolving custom-setup dependencies
 
-* Add an option to force `arch-hs` to run even if the target is in [community] 
+- Add an option to force `arch-hs` to run even if the target is in [community]
 
-* Adopt [Diff](https://hackage.haskell.org/package/Diff) in `arch-hs-diff` and `arch-hs-submit`
+- Adopt [Diff](https://hackage.haskell.org/package/Diff) in `arch-hs-diff` and `arch-hs-submit`
 
-* Fix the bug that `ghc` is missing in depends
+- Fix the bug that `ghc` is missing in depends
 
-* Fix typo ([#35](https://github.com/berberman/arch-hs/pull/35))
+- Fix typo ([#35](https://github.com/berberman/arch-hs/pull/35))
 
-* Update dependencies ([#34](https://github.com/berberman/arch-hs/pull/34))
+- Update dependencies ([#34](https://github.com/berberman/arch-hs/pull/34))
 
 ## 0.5.0.0
 
-* Add `TargetDisappearException` to complain if target is clearly not reachable
+- Add `TargetDisappearException` to complain if target is clearly not reachable
 
-* Warn abnormal dependencies
+- Warn abnormal dependencies
 
-* Clear trace file if is not empty
+- Clear trace file if is not empty
 
-* Collect test dependencies recursively
+- Collect test dependencies recursively
 
-* Drop meaningless `alpm_errno_t`
+- Drop meaningless `alpm_errno_t`
 
-* Update name preset ([#30](https://github.com/berberman/arch-hs/pull/30) [#32](https://github.com/berberman/arch-hs/pull/32))
+- Update name preset ([#30](https://github.com/berberman/arch-hs/pull/30) [#32](https://github.com/berberman/arch-hs/pull/32))
 
-* Fix a typo ([#29](https://github.com/berberman/arch-hs/pull/29))
+- Fix a typo ([#29](https://github.com/berberman/arch-hs/pull/29))
 
 ## 0.4.0.0
 
-* [Alpm](https://www.archlinux.org/pacman/libalpm.3.html) support
+- [Alpm](https://www.archlinux.org/pacman/libalpm.3.html) support
 
-* Fix sub-libraries handling ([#22](https://github.com/berberman/arch-hs/issues/22))
+- Fix sub-libraries handling ([#22](https://github.com/berberman/arch-hs/issues/22))
 
-* Fix missing build tools ([#24](https://github.com/berberman/arch-hs/issues/24))
+- Fix missing build tools ([#24](https://github.com/berberman/arch-hs/issues/24))
 
-* Fix flag comparison in diff ([#25](https://github.com/berberman/arch-hs/issues/25))
+- Fix flag comparison in diff ([#25](https://github.com/berberman/arch-hs/issues/25))
 
-* Fix pretty printing of flags
+- Fix pretty printing of flags
 
-* Update name preset ([#26](https://github.com/berberman/arch-hs/pull/26))
+- Update name preset ([#26](https://github.com/berberman/arch-hs/pull/26))
 
 ## 0.3.0.0
 
-* Update name preset
+- Update name preset
 
-* Add check in submit
+- Add check in submit
 
 ## 0.2.0.0
 
-* More accurate naming conversion between hackage representation and archlinux representation, according to [NAME_PRESET.json](https://github.com/berberman/arch-hs/blob/master/data/NAME_PRESET.json)
+- More accurate naming conversion between hackage representation and archlinux representation, according to [NAME_PRESET.json](https://github.com/berberman/arch-hs/blob/master/data/NAME_PRESET.json)
 
-* Clearer project structure
+- Clearer project structure
 
-* More reasonable exceptions
+- More reasonable exceptions
 
-* Provide versions of haskell packages in archlinux community
+- Provide versions of haskell packages in archlinux community
 
-* Add `arch-hs-submit` executable
+- Add `arch-hs-submit` executable
 
 ## 0.1.1.0
 
-* Add uusi option
+- Add uusi option
 
 ## 0.1.0.0
 
-* Support sub-libraries ([#16](https://github.com/berberman/arch-hs/issues/16))
+- Support sub-libraries ([#16](https://github.com/berberman/arch-hs/issues/16))
 
-* Split `arch-hs-uusi` into [`uusi`](https://github.com/berberman/uusi)
+- Split `arch-hs-uusi` into [`uusi`](https://github.com/berberman/uusi)
 
-* Better performance in dependency resolving
+- Better performance in dependency resolving
 
-* Fix recommended package order
+- Fix recommended package order
 
-* Trace for dependency resolving
+- Trace for dependency resolving
 
-* More reasonable PKGBUILD template ([#17](https://github.com/berberman/arch-hs/issues/16) [#18](https://github.com/berberman/arch-hs/issues/16) [#19](https://github.com/berberman/arch-hs/issues/16) [#20](https://github.com/berberman/arch-hs/issues/16))
+- More reasonable PKGBUILD template ([#17](https://github.com/berberman/arch-hs/issues/16) [#18](https://github.com/berberman/arch-hs/issues/16) [#19](https://github.com/berberman/arch-hs/issues/16) [#20](https://github.com/berberman/arch-hs/issues/16))
 
-* Fix indentation of flags' pretty printing
+- Fix indentation of flags' pretty printing
 
 ## 0.0.0.0
 
-* Initially created.
+- Initially created.
 
 [1]: https://pvp.haskell.org
 [2]: https://github.com/berberman/arch-hs/releases
diff --git a/app/Main.hs b/app/Main.hs
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -97,7 +97,7 @@
       forM_ children $ putStrLn . unPackageName
 
   unless (null abnormalDependencies || noSkipMissing) $
-    printWarn "Those package(s) are ignored unless you specify --no-skip-missing"
+    printWarn "Above package(s) are ignored unless you specify --no-skip-missing"
 
   let fillProvidedPkgs provideList provider = map (\x -> if (x ^. pkgName) `elem` provideList then ProvidedPackage (x ^. pkgName) provider else x)
       fillProvidedDeps provideList provider = map (pkgDeps %~ each %~ (\y -> if y ^. depName `elem` provideList then y & depProvider ?~ provider else y))
@@ -138,7 +138,7 @@
   -- add sign for missing children if we have
   embed . putDoc $ (prettyDeps . reverse $ map (\x -> (x, x `elem` missingChildren)) flattened) <> line <> line
 
-  unless (null missingChildren) $
+  unless (null missingChildren || not noSkipMissing) $
     embed . putDoc $ annotate italicized $ yellowStarInParens <+> "indicates a missing package" <> line <> line
 
   let sysDepsToBePacked = Map.filterWithKey (\k _ -> k `elem` flattened) sysDeps
diff --git a/arch-hs.cabal b/arch-hs.cabal
--- a/arch-hs.cabal
+++ b/arch-hs.cabal
@@ -1,6 +1,6 @@
 cabal-version:      2.4
 name:               arch-hs
-version:            0.10.0.0
+version:            0.10.1.0
 synopsis:           Distribute hackage packages to archlinux
 description:
   @arch-hs@ is a command-line program, which simplifies the process of producing
@@ -15,7 +15,7 @@
 license-file:       LICENSE
 author:             berberman
 maintainer:         berberman <berberman@yandex.com>
-copyright:          (c) 2020-2021 berberman
+copyright:          (c) 2020-2022 berberman
 category:           Distribution
 build-type:         Simple
 extra-source-files: data/NAME_PRESET.json
@@ -36,7 +36,7 @@
 
 common common-options
   build-depends:
-    , aeson                        ^>=1.5.4
+    , aeson                        >=1.5.4   && <2.1
     , algebraic-graphs             >=0.5     && <0.7
     , arch-web                     ^>=0.1.0
     , base                         >=4.12    && <5
@@ -57,10 +57,10 @@
     , microlens-th                 ^>=0.4.3
     , neat-interpolation           ^>=0.5.1
     , optparse-simple              ^>=0.1.1.3
-    , polysemy                     ^>=1.5.0 || ^>=1.6.0
+    , polysemy                     >=1.5.0   && <1.7.2
     , prettyprinter                ^>=1.7.0
     , prettyprinter-ansi-terminal  ^>=1.1.2
-    , servant-client               ^>=0.18.2
+    , servant-client               >=0.18.2  && <0.20
     , split                        ^>=0.2.3
     , tar-conduit                  ^>=0.3.2
     , template-haskell             ^>=2.16.0 || ^>=2.17.0
diff --git a/data/NAME_PRESET.json b/data/NAME_PRESET.json
--- a/data/NAME_PRESET.json
+++ b/data/NAME_PRESET.json
@@ -67,6 +67,7 @@
   "haskell-safesemaphore": "SafeSemaphore",
   "haskell-sha": "SHA",
   "haskell-smtlib": "smtLib",
+  "haskell-src": "haskell-src",
   "haskell-src-exts": "haskell-src-exts",
   "haskell-src-exts-util": "haskell-src-exts-util",
   "haskell-src-meta": "haskell-src-meta",
diff --git a/src/Distribution/ArchHs/Core.hs b/src/Distribution/ArchHs/Core.hs
--- a/src/Distribution/ArchHs/Core.hs
+++ b/src/Distribution/ArchHs/Core.hs
@@ -1,5 +1,6 @@
 {-# LANGUAGE RecordWildCards #-}
 {-# LANGUAGE TypeApplications #-}
+{-# LANGUAGE ViewPatterns #-}
 
 -- | Copyright: (c) 2020-2021 berberman
 -- SPDX-License-Identifier: MIT
@@ -34,6 +35,7 @@
 import Distribution.ArchHs.Hackage
   ( getLatestCabal,
     getLatestSHA256,
+    getPackageFlag,
   )
 import Distribution.ArchHs.Internal.Prelude
 import Distribution.ArchHs.Local (ignoreList)
@@ -76,17 +78,8 @@
   flagAssignments <- ask
   let name = getPkgName' cabal
       packageFlags = genPackageFlags cabal
-      defaultFlagAssignments =
-        foldr (\f acc -> insertFlagAssignment (flagName f) (flagDefault f) acc) (mkFlagAssignment []) packageFlags
-      flagAssignment = case Map.lookup name flagAssignments of
-        Just f -> unFlagAssignment f
-        _ -> []
-      flagNames = fmap fst flagAssignment
-      thisFlag =
-        mkFlagAssignment
-          . (<> flagAssignment)
-          . filter (\(fName, _) -> fName `notElem` flagNames)
-          $ unFlagAssignment defaultFlagAssignments
+      flagAssignment = getFlagAssignment name flagAssignments
+      thisFlag = defaultFlags packageFlags flagAssignment
   trace' $ "Evaluating condition tree of " <> show name
   trace' $ "Flags: " <> show thisFlag
   traceCallStack
@@ -178,7 +171,7 @@
   nextExe <- processNext $ fmap snd filteredExeDeps
   -- TODO: maybe unstable
   nextTest <- processNext $ fmap snd filteredTestDeps
-  nextSubLibs <- mapM (getDependencies skip (Just name)) $ fmap snd filteredSubLibDeps
+  nextSubLibs <- processNext $ fmap snd filteredSubLibDeps
   let temp = [nextLib, nextSetup, nextExe, nextTest, nextSubLibs]
       nexts = G.overlays $ temp ^. each ^.. each . _1
       subsubs = temp ^. each ^.. each . _2 ^. each
@@ -297,6 +290,10 @@
 cabalToPkgBuild pkg uusi sysDeps = do
   let name = pkg ^. pkgName
   cabal <- packageDescription <$> getLatestCabal name
+  pkgFlags <- getPackageFlag name
+  assignment <- getFlagAssignment name <$> ask
+  let showFlagForCmd (unFlagName -> fName, enabled) = "-f" <> (if enabled then "" else "-") <> fName
+      _flags = unwords . fmap showFlagForCmd . unFlagAssignment $ defaultFlags pkgFlags assignment
   _sha256sums <- (\case Just s -> "'" <> s <> "'"; Nothing -> "'SKIP'") <$> getLatestSHA256 name
   let _hkgName = pkg ^. pkgName & unPackageName
       _pkgName = unArchLinuxName . toArchLinuxName $ pkg ^. pkgName
diff --git a/src/Distribution/ArchHs/PkgBuild.hs b/src/Distribution/ArchHs/PkgBuild.hs
--- a/src/Distribution/ArchHs/PkgBuild.hs
+++ b/src/Distribution/ArchHs/PkgBuild.hs
@@ -49,7 +49,9 @@
     -- | Whether generate @prepare()@ bash function which calls @uusi@
     _enableUusi :: Bool,
     -- | Whether generate @check()@ bash function
-    _enableCheck :: Bool
+    _enableCheck :: Bool,
+    -- | Command-line flags
+    _flags :: String
   }
 
 -- | Map 'LicenseId' to 'ArchLicense'. License not provided by system will be mapped to @custom:...@.
@@ -105,6 +107,10 @@
       )
       (if _enableUusi then "\n" <> uusi <> "\n\n" else "\n")
       (if _enableCheck then "\n" <> check <> "\n\n" else "\n")
+      ( pack $ case _flags of
+          [] -> ""
+          xs -> "\\\n" <> xs
+      )
 
 -- | Text of @check()@ function.
 check :: Text
@@ -133,8 +139,8 @@
 |]
 
 -- | A fixed template of haskell package in archlinux. See <https://wiki.archlinux.org/index.php/Haskell_package_guidelines Haskell package guidelines> .
-felixTemplate :: Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text
-felixTemplate hkgname pkgname pkgver pkgdesc url license depends makedepends sha256sums licenseF uusiF checkF =
+felixTemplate :: Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text
+felixTemplate hkgname pkgname pkgver pkgdesc url license depends makedepends sha256sums licenseF uusiF checkF flags =
   [text|
   # This file was generated by https://github.com/berberman/arch-hs, please check it manually.
   # Maintainer: Your Name <youremail@domain.com>
@@ -159,7 +165,7 @@
       --prefix=/usr --docdir=/usr/share/doc/$$pkgname --enable-tests \
       --dynlibdir=/usr/lib --libsubdir=\$$compiler/site-local/\$$pkgid \
       --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \
-      --ghc-option='-pie'
+      --ghc-option='-pie' $flags
 
     runhaskell Setup build
     runhaskell Setup register --gen-script
diff --git a/src/Distribution/ArchHs/Utils.hs b/src/Distribution/ArchHs/Utils.hs
--- a/src/Distribution/ArchHs/Utils.hs
+++ b/src/Distribution/ArchHs/Utils.hs
@@ -39,11 +39,15 @@
     mapDiff,
     unDiff,
     archHsVersion,
+    defaultFlags,
+    getFlagAssignment,
   )
 where
 
 import Control.Monad ((<=<))
 import Data.Algorithm.Diff
+import qualified Data.Map.Strict as Map
+import Data.Maybe (fromMaybe)
 import Distribution.ArchHs.Internal.Prelude
 import Distribution.ArchHs.Local (ghcLibList)
 import Distribution.ArchHs.Types
@@ -235,3 +239,23 @@
 -- | The version of arch-hs
 archHsVersion :: String
 archHsVersion = $(simpleVersion Path.version)
+
+-- | Take default flag values of @pkgFlag@ overriden by @assignment@
+defaultFlags :: [PkgFlag] -> FlagAssignment -> FlagAssignment
+defaultFlags pkgFlags assignment = result
+  where
+    defaultFlagAssignments =
+      foldr (\f acc -> insertFlagAssignment (flagName f) (flagDefault f) acc) (mkFlagAssignment []) pkgFlags
+    flagAssignment = unFlagAssignment assignment
+    flagNames = fmap fst flagAssignment
+    result =
+      mkFlagAssignment
+        . (<> flagAssignment)
+        . filter (\(fName, _) -> fName `notElem` flagNames)
+        $ unFlagAssignment defaultFlagAssignments
+
+-- | Get 'FlagAssignment' from 'FlagAssignments'
+--
+-- Returns an empty FlagAssignment if no corresponding package in 'FlagAssignments'
+getFlagAssignment :: PackageName -> FlagAssignments -> FlagAssignment
+getFlagAssignment k v = fromMaybe (mkFlagAssignment []) $ k `Map.lookup` v
